import React, { Component } from 'react'
import {  InputItem,Toast } from 'antd-mobile';
import styles from './Login.module.scss'
class Login extends Component {
  handClick = () => {
    if(!this.autoFocusInst.state.value){
      Toast.info("账号不能为空", 1);
      return
    }
    if(!this.inputRef.state.value){
      Toast.info("密码不能为空", 1);
      return
    }
    Toast.info("登录成功", 1);
    this.props.history.push('/booktown')
    localStorage.setItem('took',JSON.stringify(this.autoFocusInst.state.value))
  }
  
  render() {
    return (
      <div>
        <div className={styles.title}>登录</div>
        <InputItem
            type = 'phone'
            clear
            placeholder="请输入账号"
            ref={el => this.autoFocusInst = el}
          >账号</InputItem>
          <InputItem
          type = 'password'
            clear
            placeholder="请输入密码"
            ref={el => this.inputRef = el}
          >密码</InputItem>
          <div className={styles.foot} onClick={this.handClick}>登录</div>
      </div>
    )
  }
}

export default Login;
